package com.taobao.dao.impl;

import java.util.List;

import com.taobao.dao.CommonDBDao;
import com.taobao.dao.ReceiveSaveDBDao;
import com.taobao.pojo.Config;
import com.taobao.pojo.DBContext;
import com.taobao.pojo.Task;

public class ReceiveSaveDBDaoImpl extends CommonDBDao implements ReceiveSaveDBDao{

	@Override
	public void saveTasks(List<Task> tasks) throws Exception {
		for (int i = 0; i < tasks.size(); i++) {
			Task task = tasks.get(i);
			String sql = "insert into receive values(";
			sql = sql + "'" + Config.userName + "', ";
			sql = sql + "'" + task.getId() + "', ";
			sql = sql + "'" + task.getName() + "', ";
			sql = sql + "'" + task.getTbName() + "', ";
			sql = sql + task.getPublishPoint() + ", ";
			sql = sql + task.getPrice() + ", ";
			sql = sql + "datetime('" + task.getPublishTime() + "'), ";
			sql = sql + "'" + task.getSmallUser() + "', ";
			sql = sql + "'" + task.getConfirmTime().toString() + "', ";
			sql = sql + "'" + task.getHpWord() + "', ";
			sql = sql + "'" + task.getTbUrl() + "');";
			System.out.println(sql);
			if(i == tasks.size() - 1){
				saveRequest(sql, true);
			} else {
				saveRequest(sql, false);
			}
		}
	}

	@Override
	public Object process(DBContext context) throws Exception {
		return null;
	}

}
